<!DOCTYPE html>
<html>
	<head>
		<include file="public:meta" />
		<link rel="stylesheet" href="../public/css/personal.css">
		<link rel="stylesheet" href="../public/css/nprogress.css">
	</head>
	<body>
		<include file="public:header"/>

		<div class="list_height plist-txt notarrow">
	        <div class="pic"></div>
	        <div class="tit font14">作品描述</div>
	        <div class="describe font13">
	            <input type="text" id="title" placeholder="请输入作品描述" value="{$info['title']}">
	        </div>
	        <div class="arrow"></div>
	        <div class="clear"></div>
	    </div>

		<div class="list_height plist-txt notarrow last	">
			<div class="pic"></div>
			<div class="tit font14">上传作品<span class="font_red_light">*</span></div>
			<div class="describe com_auth_add_btn font13">
				<div class="qs-btn qs-btn-inline qs-btn-green qs-btn-medium mt125">
					<span class="js-up-txt">上传作品</span>
					<input type="file" id="browseFile" class="browseFile">
				</div>
				<input type="hidden" id="certificate_img_up" name="certificate_img_up" value="{$info['img']}">
			</div>
			<div class="arrow"></div>
			<div class="clear"></div>
		</div>

		<div class="split-block"></div>
		<div class="qs-center m-auth-img-box-group <if condition="$info['img'] eq ''">qs-hidden</if>">
			<div class="m-auth-img-box photo-works">
				<img src="{:attach($info['img'],'resume_img')}">
			</div>
		</div>
		<div class="btn-spacing">
			<a id="J_saveresume"  href="javascript:;" class="qs-btn qs-btn-blue font18">保存</a>
		</div>
		<div class="split-block"></div>
		<include file="public:footer_min"/>
		<script src="../public/js/mobileBUGFix.mini.js"></script>
		<script src="../public/js/LocalResizeIMG.js"></script>
		<script src="../public/js/nprogress.js"></script>
		<script type="text/javascript">
			$('#browseFile').localResizeIMG({
				width: 400,
				quality: 1,
				success: function (result) {  
					var submitData={
						base64_string:result.clearBase64, 
					};
					NProgress.start();
					$.ajax({
						type: "POST",
						url: "{:U('upload/resume_img')}",
						data: submitData,
						dataType:"json",
						success: function(result){
							NProgress.done();
							if(result.status == 1){
								$('#certificate_img_up').val(result.data.img);
								$('.m-auth-img-box').html('<img src="' + result.data.path + '">');
								$('.m-auth-img-box-group').removeClass('qs-hidden');
								$('.js-up-txt').text('重新选择');
							}else{
								qsToast({type:2,context:result.msg});
							}
						}, 
						complete :function(XMLHttpRequest, textStatus){},
						error:function(XMLHttpRequest, textStatus, errorThrown){ //上传失败 
							qsToast({type:2,context: '图片上传失败！'});
						}
					}); 
				}
			});
			$('#J_saveresume').on('click',function(){
				var title = $.trim($('#title').val());
	            var img = $.trim($('#certificate_img_up').val());
				var id = "{$Think.get.id}";
				var pid = "{$resume.id}";
				var news = "{$Think.get.news}";
				/*if (title == "") {
					qsToast({type:2,context: '请填写作品描述'});
					return false;
				}*/
				if (img == "") {
					qsToast({type:2,context: '请上传作品'});
					return false;
				}
				$('#J_saveresume').val('保存中...').addClass('qs-btn-border-disabled');
	            // 提交表单
	            $.ajax({
	                url: "{:U('Personal/resume_edit_img')}",
	                type: 'POST',
	                dataType: 'json',
	                data: {pid:pid,id:id,title:title,img:img,news:news},
	                success:function(data){
	                    if (data.status == 1) {
	                        window.location.href = data.data.url;
	                    } else {
	                        qsToast({type:2,context: data.msg});
	                        $('#J_saveresume').val('保存').removeClass('qs-btn-border-disabled');
	                    }
	                },
	                error:function(result){
	                    $('#J_saveresume').val('保存').removeClass('qs-btn-border-disabled');
	                    qsToast({type:2,context: result.msg});
	                }
	            });
			});
		</script>
	</body>
</html>